package com.heima.bos.web.action.impl;

import java.io.IOException;
import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.heima.bos.domain.Role;
import com.heima.bos.service.BaseService;
import com.heima.bos.service.RoleService;
import com.heima.bos.web.action.RoleActionInter;
@Controller
@Scope("prototype")
public class RoleAction extends BaseAction<Role> implements RoleActionInter{
	@Resource
	private RoleService roleService;
	//属性注入权限ids
	private String ids;
	

	/**
	 * 添加角色
	 * 重写save方法
	 * 	*之前需要获取权限列表进行页面初始化
	 */
	public String save(){
		
		roleService.save(entity,ids);
		return "addSuccess";
	}
	/**
	 * 查询所有角色返回json数据
	 */
	public String list(){
		
		List<Role> list = roleService.findAll();
		String[] excludes = new String[]{"functions","users","code"};
		writeList2Json(list, excludes);
		return NONE;
	}
	@Override
	protected BaseService<Role> getService() {
		return roleService;
	}
	public void setIds(String ids) {
		this.ids = ids;
	}
}
